# 测试种子数据脚本
Write-Host "🎯 测试种子数据" -ForegroundColor Cyan
Write-Host "==================" -ForegroundColor Cyan

# 启动应用程序
Write-Host "🚀 启动应用程序..." -ForegroundColor Yellow
Start-Process -FilePath "dotnet" -ArgumentList "run", "--project", "src/TerritoryGame.API" -WindowStyle Hidden

# 等待应用程序启动
Write-Host "⏳ 等待应用程序启动..." -ForegroundColor Yellow
Start-Sleep -Seconds 10

# 测试API端点
Write-Host "🔍 测试API端点..." -ForegroundColor Yellow

try {
    $response = Invoke-RestMethod -Uri "http://localhost:5000/api/queries/rooms" -Method Get
    Write-Host "✅ 成功获取房间列表" -ForegroundColor Green
    Write-Host "📊 房间数量: $($response.Count)" -ForegroundColor Green
    
    if ($response.Count -gt 0) {
        Write-Host "🎉 种子数据已成功添加！" -ForegroundColor Green
        Write-Host "📋 房间列表:" -ForegroundColor Cyan
        foreach ($room in $response) {
            Write-Host "  - $($room.name) (玩家: $($room.playerCount)/$($room.maxPlayers))" -ForegroundColor White
        }
    } else {
        Write-Host "⚠️ 没有找到房间数据" -ForegroundColor Yellow
    }
} catch {
    Write-Host "❌ 无法连接到API: $($_.Exception.Message)" -ForegroundColor Red
}

# 停止应用程序
Write-Host "🛑 停止应用程序..." -ForegroundColor Yellow
Get-Process -Name "dotnet" -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -eq "dotnet" } | Stop-Process -Force

Write-Host "✅ 测试完成!" -ForegroundColor Green
